package com.crazyhat.crazyhat.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.hibernate.validator.constraints.URL;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.crazyhat.crazyhat.anno.SensitiveWordAnno;
import com.crazyhat.crazyhat.attribute.GenderEnum;
import com.crazyhat.crazyhat.attribute.UserTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author crazyhat
 * @since 2024-07-05
 */
@Getter
@Setter
@TableName("user")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 学号
     */
    @TableId(value = "student_id",type = IdType.INPUT)
    private Integer studentId;

    /**
     * 姓名
     */
    @SensitiveWordAnno
    @TableField("name")
    private String name;

    /**
     * 性别
     */
    @TableField("gender")
    private GenderEnum gender;

    /**
     * 年龄
     */
    @TableField("age")
    private Integer age;

    /**
     * 头像地址
     */
    @URL
    @TableField("avatar_url")
    private String avatarUrl;

    /**
     * 邮箱
     */
    @Email
    @TableField("email")
    private String email;

    /**
     * 密码
     */
    @JsonIgnore
    @TableField("password")
    private String password;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 用户类别
     */
    @JsonIgnore
    @TableField(value = "user_type")
    private UserTypeEnum userType;
}
